<template>
	<view>
		<view class="u-page">
			<!-- 所有内容的容器 -->
			<home v-if="current == 0"></home>
			<invitation v-if="current == 1"></invitation>
			<publish v-if="current == 2"></publish>
			<collect v-if="current == 3"></collect>
			<me v-if="current == 4"></me>
		</view>
		<!-- 与包裹页面所有内容的元素u-page同级，且在它的下方 -->
		<u-tabbar v-model="current" :list="list" :mid-button="false"></u-tabbar>
	</view>
</template>

<script>
	import helper from '../../common/helper.js'
	import home from './home'
	import invitation from './invitation'
	import me from "./me"
	import publish from "./publish"
	import collect from "./collect"
	export default {
		components: {
			home,
			me,
			publish,
			collect,
			invitation
		},
		data() {
			return {
				list: [{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						isDot: false,
						customIcon: false,
					},
					{
						iconPath: "file-text",
						selectedIconPath: "file-text-fill",
						text: '帖子',
						customIcon: false,
					},
					{
						iconPath: "edit-pen",
						selectedIconPath: "edit-pen-fill",
						text: '发布',
						midButton: true,
						customIcon: false,
					},
					{
						iconPath: "shopping-cart",
						selectedIconPath: "shopping-cart-fill",
						text: '购物车',
						count: 0,
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
						isDot: false,
						customIcon: false,
					},
				],
				current: 0
			}
		},
		onLoad() {

		},
		created(){
			this.lookCollect()
		},
		methods: {
			lookCollect() {
				
				let that = this
				let user = uni.getStorageSync("user")
				let data = {
					userId: user.id,
					shopId: "",
					type: 1
				}
				that.postRequest(helper.lookCollect, data).then(res => {
					if (res.data.flag == "200") {
						let serve = res.data
						that.list[3].count = serve.collectNum
					}
				})
			},
		},
		watch:{
			current(){
				this.lookCollect()
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
